<template>
    <div>
        <Modal
            v-model="showBox"
            title="提现中心"
            :mask-closable="false"
        >
            <p style="font-size: 16px;">请填写提现金额</p>
            <p class="cRed" style="font-size: 14px;margin-bottom: 10px">(提现金额必须大于100元，3个工作日内到账)</p>
            <Input v-model="money" ref="money" type="number" prefix="logo-yen" placeholder="金额(元)" style="width: 320px" 
            onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
            />
            <p style="margin-top: 10px">当前收益余额: {{partner_profit?partner_profit:0}}元</p>
            <div slot="footer">
                <Button type="text" size="large" @click="showBox=false">取消</Button>
                <Button type="primary" size="large" @click="ok">确定</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
    export default {
        name: "earningsBox",
        data () {
            return {
                showBox: false,
                money:'',// 输入的提现金额
                partner_profit:0,// 可提现金额
            }
        },
        methods: {
            ok () {
                const money = this.money;
                if($app.judgeData($app.delSpace(money))){
                    if(money>=100){

                        $ajax.lb_getWithdrawal({money}, res => {
                            this.$parent.$emit('up_cAll');// 执行父亲的方法
                            $app.toast(res.msg,true);//提现成功 提示语
                            this.showBox=false;//隐藏弹框
                        });
                        
                    }else{
                        $app.alert('提现金额必须大于100元','温馨提示',()=>{
                            this.$refs['money'].focus();
                        });
                    }
                    
                }else{
                    $app.alert('请输入开票金额','温馨提示',()=>{
                        this.$refs['money'].focus();
                    });
                }
                
            }
        },
    }
</script>

<style scoped>

</style>